package com.dragon.modules.yuegou.enums.order;

import com.fasterxml.jackson.annotation.JsonCreator;

import java.util.Map;
import java.util.stream.Collectors;
import java.util.stream.Stream;

/**
 * 提货类型
 * 
 * @author pbuilder generated
 *
 */
public enum OrderPickupType {

	/**
	 * 上门提货
	 */
	SELF(0, "上门提货"),
	/**
	 * 线上授予
	 */
	ONLINE(1, "线上授予"),
	/**
	 * 商户送货
	 */
	MERCHANT(2, "商户送货"),
	/**
	 * 快递
	 */
	POST(3, "快递");

	/**
	 * 枚举标识
	 */
	private final Integer code;

	/**
	 * 别名
	 */
	private final String alias;

	private OrderPickupType(Integer code, String alias) {
		this.code = code;
		this.alias = alias;
	}
	
	public Integer getValue() {
		return code;
	}

	/**
	 * 枚举标识
	 * 
	 * @return code
	 */
	public Integer getCode() {
		return code;
	}

	/**
	 * 别名
	 * 
	 * @return alias
	 */
	public String getAlias() {
		return alias;
	}

	/**
	 * 把code转化为费用类型枚举
	 * 
	 * @param code 代码
	 * @return
	 */
	@JsonCreator
	public static OrderPickupType from(Integer code) {
		if (code == null) {
			return null;
		}
		return CODE_MAP.get(code);
	}

	/**
	 * Code Map for OrderPickupType
	 */
	private static final Map<Integer, OrderPickupType> CODE_MAP = Stream.of(OrderPickupType.values())
			.collect(Collectors.toMap(OrderPickupType::getCode, e -> e));

}
